#! /bin/awk -f
# Author : Raman Rawat
# renames the input file/dir as per the replacement strings
#  Variables   r() and Replacement are passed as "-v r=XXXX Replacement=YYYY"
#  
#awk -v start="${startLine}" -v end="${endLine}"   ' { if(NR > start && NR < end) print "name:"$2",  type:"$1 }'  $modifiedCatalog
#feature CATOsmItem #startup 
#  string font_name  #in
#  double font_size  #out
#  boolean underline  #neutral 
#  int background #list #out // list of style  
#  int foreground

BEGIN {
	print "# tdd file generated by .awk script"
	print "{"
}

{
#print "length of " $1 "is" length($1) 
if(NR == start ) {

# Read line for LateType name.
#feature CATOsmItem #startup 
print "SuperType:GSMGeom"
print "LateType:"$2
print "Attributes:["
}

if(NR > start && NR < end) {

	#		{"name":"Point"			, "type":"spec"			, "facet":"IN"		, "list":"n" , "ui":"sellist",  "data":[]},

	list="n"
	type=$1
	if( $1 == "int"){
	type="integer"
	} 
	
	# Substring starting from index 2 - remove the first char "#"
	facet=substr($3, 2)
	if( $3 == "#list"){
	type="tklist_"type
	list="y"
	facet=substr($4, 2)
	} else {
	type="tk_"type	
	}
		
	print "\t{ name:"$2",  type:"type",\t facet:"toupper(facet)", list:"list"}, "

	 }
}
END {
	print "]"
	print "}"
}
